import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeviceVo } from '@/api/device/types';

/**
 * 查询列表
 * @param query
 * @returns {*}
 */

export const listDevice = (query?: PageQuery): AxiosPromise<DeviceVo[]> => {
  return request({
    url: '/biz-device/device/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询列表（站房设备）
 * @param query
 * @returns {*}
 */

export const listStationDevice = (query?: PageQuery): AxiosPromise<DeviceVo[]> => {
  return request({
    url: '/biz-device/device/list',
    method: 'get',
    params: { ...query, deviceTypes: ['4', '5', '6', '7'] }
  });
};

/**
 * 查询列表（酒店设备）
 * @param query
 * @returns {*}
 */

export const listVendorDevice = (query?: PageQuery): AxiosPromise<DeviceVo[]> => {
  return request({
    url: '/biz-device/device/list',
    method: 'get',
    params: { ...query }
  });
};

/**
 * 查询详细
 * @param id
 */
export const getDevice = (id: string | number): AxiosPromise<DeviceVo> => {
  return request({
    url: '/biz-device/device/id/' + id,
    method: 'get'
  });
};

/**
 * 新增
 * @param data
 */
export const addDevice = (data: DeviceVo) => {
  return request({
    url: '/biz-device/device',
    method: 'post',
    data: data
  });
};

/**
 * 修改
 * @param data
 */
export const updateDevice = (data: DeviceVo) => {
  return request({
    url: '/biz-device/device',
    method: 'put',
    data: data
  });
};

/**
 * 作废
 * @param data
 */
export const abolishDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-device/device/invalid/' + id,
    method: 'put'
  });
};

/**
 * 更换
 * @param data
 */
export const changeDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-device/device/change/' + id,
    method: 'put'
  });
};

/**
 * 删除
 * @param id
 */
export const delDevice = (id: string | number | Array<string | number>) => {
  return request({
    url: '/biz-device/device/' + id,
    method: 'delete'
  });
};

/**
 * 设备部署绑定
 * @param data
 */
export const deploymentDevice = (data: DeviceVo) => {
  return request({
    url: '/biz-device/device/deployment',
    method: 'put',
    data: data
  });
};
